package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.AGAINVISIT;
import com.ruoyi.system.service.IAGAINVISITService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 学生回访管理Controller
 * 
 * @author ruoyi
 * @date 2021-11-09
 */
@Controller
@RequestMapping("/system/AGAINVISIT")
public class AGAINVISITController extends BaseController
{
    private String prefix = "system/AGAINVISIT";

    @Autowired
    private IAGAINVISITService aGAINVISITService;

    @RequiresPermissions("system:AGAINVISIT:view")
    @GetMapping()
    public String AGAINVISIT()
    {
        return prefix + "/AGAINVISIT";
    }

    /**
     * 查询学生回访管理列表
     */
    @RequiresPermissions("system:AGAINVISIT:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(AGAINVISIT aGAINVISIT)
    {
        startPage();
        List<AGAINVISIT> list = aGAINVISITService.selectAGAINVISITList(aGAINVISIT);
        return getDataTable(list);
    }

    /**
     * 导出学生回访管理列表
     */
    @RequiresPermissions("system:AGAINVISIT:export")
    @Log(title = "学生回访管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(AGAINVISIT aGAINVISIT)
    {
        List<AGAINVISIT> list = aGAINVISITService.selectAGAINVISITList(aGAINVISIT);
        ExcelUtil<AGAINVISIT> util = new ExcelUtil<AGAINVISIT>(AGAINVISIT.class);
        return util.exportExcel(list, "学生回访管理数据");
    }

    /**
     * 新增学生回访管理
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存学生回访管理
     */
    @RequiresPermissions("system:AGAINVISIT:add")
    @Log(title = "学生回访管理", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(AGAINVISIT aGAINVISIT)
    {
        return toAjax(aGAINVISITService.insertAGAINVISIT(aGAINVISIT));
    }

    /**
     * 修改学生回访管理
     */
    @GetMapping("/edit/{studentName}")
    public String edit(@PathVariable("studentName") String studentName, ModelMap mmap)
    {
        AGAINVISIT aGAINVISIT = aGAINVISITService.selectAGAINVISITByStudentName(studentName);
        mmap.put("aGAINVISIT", aGAINVISIT);
        return prefix + "/edit";
    }

    /**
     * 修改保存学生回访管理
     */
    @RequiresPermissions("system:AGAINVISIT:edit")
    @Log(title = "学生回访管理", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(AGAINVISIT aGAINVISIT)
    {
        return toAjax(aGAINVISITService.updateAGAINVISIT(aGAINVISIT));
    }

    /**
     * 删除学生回访管理
     */
    @RequiresPermissions("system:AGAINVISIT:remove")
    @Log(title = "学生回访管理", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(aGAINVISITService.deleteAGAINVISITByStudentNames(ids));
    }
}
